package net.tycmc.cty.ctyms.timejob.iems.dao;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.tycmc.functions.util.MapGetter;

import net.tycmc.bulb.common.dao.IBaseDAO;
import net.tycmc.bulb.common.dao.ITransactionDAO;
import net.tycmc.bulb.common.util.StringUtil;
import net.tycmc.bulb.dbutil.global.GlobalDBVar;
import net.tycmc.cty.ctyms.timejob.common.EquipVersionCommon;
import net.tycmc.cty.ctyms.timejob.common.MyConnectDSDAO;
import net.tycmc.cty.ctyms.timejob.common.MyConnectDSTransDAO;

public class DataMissingMonitorDao {
	private IBaseDAO baseDAO;
	private ITransactionDAO tranDAO;
	private MyConnectDSTransDAO ms=new MyConnectDSTransDAO();
	private MyConnectDSDAO msd=new MyConnectDSDAO();
	public ITransactionDAO getTranDAO() {
		return tranDAO;
	}
	public void setTranDAO(ITransactionDAO tranDAO) {
		this.tranDAO = tranDAO;
	}
	public IBaseDAO getBaseDAO() {
		return baseDAO;
	}
	public void setBaseDAO(IBaseDAO baseDAO) {
		this.baseDAO = baseDAO;
	}
	
	/**从标记表中获取上次的统计时间
	 * @return
	 */
	public List<Map<String,Object>> getFlagOfMitor(){
		StringBuffer Mql=new StringBuffer();
		Mql.append("select pcf_id,convert(varchar(10),pcf_FinalmsgTime,120)pcf_FinalmsgTime,pcf_flagid,pcf_remark from ParamCollectFlag order by pcf_flagid");
		return  baseDAO.execQuery(Mql.toString(), new Object[]{});
	}
	/**
	 * dateTime :要统计的时间
	 * @return
	 */
	/**
	 * 从运行油耗统计中，查询发动机开机时长大于0.5的设备
	 * @param dateTime 本次统计时间
	 * @param argType 设备协议版本
	 * @param type job类型（1:参数未统计  2:采集频率不是一分钟）
	 * @return
	 */
	public List<Map<String,Object>>getVclEcmRunMoref(String dateTime,String argType,String type){
		StringBuffer Mql=new StringBuffer();
		String TableTime=dateTime.substring(0,10).replaceAll("-","");
		Mql.append("select MsgESS_SwitchOn,MsgESS_iWork egnOnTime,vv.vehicleid vclId,ISNULL(recordNum,0)recordNum,vt.TerminalID,aa.vcl_Id,vehiclenumber,MsgESS_MsgTime='"+dateTime+"'  from "+GlobalDBVar.getDBFullName_Conn("Msg_EquipmentState_Statistics_"+TableTime, "3", null));
		Mql.append(" inner join v_vehicleinfo vv on MsgESS_Vcl_ID=vv.vehicleid ");
		Mql.append(" inner join V_Tmnl_Install vt on vv.Vehicleid=vt.Vehicleid and installtime <getdate() and BackoutTime>getdate() ");
		if(argType.equals("VPEVcl_D")){//大一设备，参数来自CTY_EGN_A.MSG_TIMING_XXXX
			Mql.append("left join (select msgt_vcl_id vcl_Id ,count(msgt_vcl_id) recordNum  from "+GlobalDBVar.getDBFullName_Conn("Msg_Timing_"+TableTime, "2", null)+" group by msgt_vcl_id)aa on aa.vcl_Id=vv.vehicleid ");
		}else if(argType.equals("VPEVcl_J")){//小一J，参数来自CTY_EGN_B.DBO.MSG_CAN_XXXX
			Mql.append("left join (select MSGC_VCL_ID vcl_Id ,count(MSGC_VCL_ID) recordNum  from "+GlobalDBVar.getDBFullName_Conn("MSG_CAN_"+TableTime, "4", dateTime)+" group by MSGC_VCL_ID)aa on aa.vcl_Id=vv.vehicleid ");
		}else if(argType.equals("VPEVcl_JPP")){//小一JPP参数，参数来自Pan参数和UDS参数
			Mql.append(" left join ( select vcl_Id ,count(vcl_Id)recordNum from ("+
					"select msgp_vcl_id vcl_Id from "+GlobalDBVar.getDBFullName_Conn("Msg_PGN_"+TableTime, "4", dateTime)+" union all "+
					"select msgu_vcl_id vcl_Id from "+GlobalDBVar.getDBFullName_Conn("Msg_UDS_"+TableTime, "4", dateTime)+" )bb group by vcl_Id)aa on aa.vcl_Id=vv.vehicleid" );
		}else{//小一pp设备，暂不考虑
			
		}
		Mql.append(" where MsgESS_State = 0 and( (subString(cast (MsgESS_Complete_1 as varchar),1,1) = 1 and charindex(cast(vehiclerumkmid as varchar)+'1',cast(MsgESS_Complete_2 as varchar)) >0)" +
				" or (subString(cast (MsgESS_Complete_1 as varchar),1,1) = 0 and charindex(cast(vehiclerumkmid as varchar)+'0',cast(MsgESS_Complete_2 as varchar)) >0) )");
		Mql.append(" and Tmnl_SoftEdition in ("+EquipVersionCommon.getSoftVerByAgrType(argType)+")");
		if("1".equals(type)){
			Mql.append(" and MsgESS_iWork>0.5");
		}
		if("2".equals(type)){
			Mql.append(" and MsgESS_SwitchOn>0.5");
		}
		System.out.println(argType+":"+Mql.toString());
		return msd.execQuery(Mql.toString(), new Object[]{});
	}
	/**存储参数未统计数据
	 * @param list
	 */
	public void saveDataNoCollectParam(List<Map<String,Object>>list,String dateTime,String isbakTable){
		List<String>listResult=new ArrayList<String>();//最终结果
		for(Map<String,Object>map:list){
			if(!StringUtil.isValid(MapGetter.getString(map,"vcl_id"))){
				listResult.add("insert into VclNoCollectParam (Vncp_vcl_id,Vncp_vclno,Vncp_msgTime,Vncp_tmnlno)" +
						"values("+MapGetter.getString(map,"vclId")+",'"+MapGetter.getString(map,"vehiclenumber")+"','"+MapGetter.getString(map,"MsgESS_MsgTime")+"','"+MapGetter.getString(map,"TerminalID")+"')");
			}
		}
		if(listResult.size()>0){
			listResult.add("update  ParamCollectFlag set pcf_FinalmsgTime='"+dateTime+"' where pcf_flagId=1");
		}
		boolean flag=this.ms.batch(listResult);
		//二期优化：是否需要备份数据
		if(isbakTable.equals("1")){
			MyConnectDSTransDAO conn=new MyConnectDSTransDAO(true);
			boolean flager=conn.batch(listResult);
			if(!flager){
				System.out.println("参数未统计备份插入失败！！");
			}
		}
		if(flag){
			System.out.println("参数未统计插入成功---------------统计"+listResult.size()+"条");
		}else{
			System.out.println("参数未统计插入失败----------------应插入"+listResult.size()+"条");
		}
		
		list=null;
		listResult=null;
	}
	/**频率大于1分钟设备存储表
	 * @param list
	 */
	public void saveDataFreMoreOMIN(List<Map<String,Object>>list,String dateTime,String isbakTable){
		List<String>listResult=new ArrayList<String>();//最终结果
		for(Map<String,Object>map:list){
			if(StringUtil.isValid(MapGetter.getString(map,"vcl_Id"))){//先判断采集到参数的设备
				double MsgESS_SwitchOn=MapGetter.getDouble(map,"MsgESS_SwitchOn");//开机时长
				int recordNum=Integer.parseInt(MapGetter.getString(map,"recordNum"));
				if(MsgESS_SwitchOn*60*2/recordNum>2){
					listResult.add("insert into VclCollectFre (Vclf_vcl_id,Vclf_vclno,Vclf_msgTime,Vclf_tmnlno,Vclf_keyOnTime,Vclf_DataRecordNum)" +
							"values("+MapGetter.getString(map,"vclId")+",'"+MapGetter.getString(map,"vehiclenumber")+"'," +
									"'"+MapGetter.getString(map,"MsgESS_MsgTime")+"','"+MapGetter.getString(map,"TerminalID")+"'," +
											""+(StringUtil.isValid(MapGetter.getString(map,"MsgESS_SwitchOn")) ? MapGetter.getString(map,"MsgESS_SwitchOn"):null)+","+recordNum+")");
					}
				}
			}
		if(listResult.size()>0){
			listResult.add("update  ParamCollectFlag set pcf_FinalmsgTime='"+dateTime+"' where pcf_flagId=2");
		}
		boolean flag=this.ms.batch(listResult);
		//二期优化：是否需要备份数据
		if(isbakTable.equals("1")){
			MyConnectDSTransDAO conn=new MyConnectDSTransDAO(true);
			boolean flager=conn.batch(listResult);
			if(!flager){
				System.out.println("频率大于1分钟备份数据插入失败！！");
			}
		}
		if(flag){
			System.out.println("频率大于1分钟成功---------------统计"+listResult.size()+"条");
		}else{
			System.out.println("频率大于1分钟插入失败");
		}
		list=null;
		listResult=null;
	}
	
	/**发动机运行时长大于0.5，无档位及车速数据
	 * @return
	 */
	public List<Map<String,Object>> getNoDB2DataList(String dateTime,String argType){
		StringBuffer Mql=new StringBuffer();
		String TableTime=dateTime.substring(0,10).replaceAll("-","");
		Mql.append(" select MsgESS_iWork engOnTime,vv.vehicleid vclId,vt.TerminalID," +
				   " vehiclenumber,MsgESS_MsgTime='"+dateTime+"'  from "+GlobalDBVar.getDBFullName_Conn("Msg_EquipmentState_Statistics_"+TableTime, "3", null));
		Mql.append(" inner join v_vehicleinfo vv on MsgESS_Vcl_ID=vv.vehicleid ");
		Mql.append(" inner join V_Tmnl_Install vt on vv.Vehicleid=vt.Vehicleid and installtime <getdate() and BackoutTime>getdate() ");
		
		Mql.append(" left join (select vehicleid ,totalCnt = ISNULL(SUM(MsgDB2_Tcount),0) from V_VehicleInfo ");
		Mql.append(" inner join (select MsgDB2_Vcl_ID,MsgDB2_Tcount from "+GlobalDBVar.getDBFullName_Conn("Msg_DriverBehavior2_"+TableTime, "3", null));
		Mql.append(" )a on VehicleID = MsgDB2_Vcl_ID where isnull(vehicleid,0)<>0 group by vehicleid)bb on bb.vehicleid=vv.vehicleid");
		
		Mql.append(" where MsgESS_iWork>0.5 and MsgESS_State = 0 and( (subString(cast (MsgESS_Complete_1 as varchar),1,1) = 1 and charindex(cast(vehiclerumkmid as varchar)+'1',cast(MsgESS_Complete_2 as varchar)) >0)" +
				   " or (subString(cast (MsgESS_Complete_1 as varchar),1,1) = 0 and charindex(cast(vehiclerumkmid as varchar)+'0',cast(MsgESS_Complete_2 as varchar)) >0) )");
		Mql.append(" and Tmnl_SoftEdition in ("+EquipVersionCommon.getSoftVerByAgrType(argType)+") and (bb.totalCnt=0 or bb.totalCnt='' or bb.totalCnt is null)");
		return baseDAO.execQuery(Mql.toString(), new Object[]{});
	}
	/**将档位及车速无数据的设备存于表中
	 * @param list
	 */
	public void saveDataNoDb2List(List<Map<String,Object>>list,String dateTime,String isbakTable){
		List<String>listResult=new ArrayList<String>();//最终结果
		for(Map<String,Object>map:list){
				listResult.add("insert into DB2OfVcl (DB2OV_vcl_id,DB2OV_vclno,DB2OV_msgTime,DB2OV_tmnlno,DB2OV_ECMrunTime)" +
						"values("+MapGetter.getString(map,"vclId")+",'"+MapGetter.getString(map,"vehiclenumber")+"'," +
								"'"+MapGetter.getString(map,"MsgESS_MsgTime")+"','"+MapGetter.getString(map,"TerminalID")+"'," +
										""+(StringUtil.isValid(MapGetter.getString(map,"engontime")) ? MapGetter.getString(map,"engontime"):null)+")");
		}
		if(listResult.size()>0){
			listResult.add("update  ParamCollectFlag set pcf_FinalmsgTime='"+dateTime+"' where pcf_flagId=3");
		}
		boolean flag=this.ms.batch(listResult);
		//二期优化：是否需要备份数据
		if(isbakTable.equals("1")){
			MyConnectDSTransDAO conn=new MyConnectDSTransDAO(true);
			boolean flager=conn.batch(listResult);
			if(!flager){
				System.out.println("将档位及车速无数据插入备份失败！！");
			}
		}
		if(flag){
			System.out.println("将档位及车速无数据成功---------------统计"+listResult.size()+"条");
		}else{
			System.out.println("将档位及车速无数据插入失败");
		}
		list=null;
		listResult=null;
	
	}
	/**获取dutyCycle无档位车速的设备集合
	 * @param dateTime
	 * @param argType
	 * @return
	 */
	public List<Map<String,Object>> getDataNoDutyCycleList(String dateTime,String argType){
		StringBuffer Mql=new StringBuffer();
		String TableTime=dateTime.substring(0,10).replaceAll("-","");
		Mql.append(" select MsgESS_iWork engOnTime,vv.vehicleid vclId,vt.TerminalID," +
				   " vehiclenumber,MsgESS_MsgTime='"+dateTime+"' from "+GlobalDBVar.getDBFullName_Conn("Msg_EquipmentState_Statistics_"+TableTime, "3", null));
		Mql.append(" inner join v_vehicleinfo vv on MsgESS_Vcl_ID=vv.vehicleid ");
		Mql.append(" inner join V_Tmnl_Install vt on vv.Vehicleid=vt.Vehicleid and installtime <getdate() and BackoutTime>getdate() ");
		Mql.append(" where MsgESS_iWork>0.5 and MsgESS_State = 0 and( (subString(cast (MsgESS_Complete_1 as varchar),1,1) = 1 and charindex(cast(vehiclerumkmid as varchar)+'1',cast(MsgESS_Complete_2 as varchar)) >0)" +
				   " or (subString(cast (MsgESS_Complete_1 as varchar),1,1) = 0 and charindex(cast(vehiclerumkmid as varchar)+'0',cast(MsgESS_Complete_2 as varchar)) >0) ) and (MsgESS_MsgDate<>'"+dateTime+"' or MsgESS_MsgDate is null or MsgESS_MsgDate='')");
		Mql.append(" and Tmnl_SoftEdition in ("+EquipVersionCommon.getSoftVerByAgrType(argType)+") ");
		return baseDAO.execQuery(Mql.toString(), new Object[]{});
	}
	/**将dutyCycle无数据的设备保存到表中
	 * @param list
	 */
	public void saveDataNoDutyCycleList(List<Map<String,Object>>list,String dateTime,String isbakTable){
		List<String>listResult=new ArrayList<String>();//最终结果
		for(Map<String,Object>map:list){
				listResult.add("insert into DCFZOfVcl (DCFZOV_vcl_id,DCFZOV_vclno,DCFZOV_msgTime,DCFZOV_tmnlno,DCFZOV_ECMrunTime)" +
						"values("+MapGetter.getString(map,"vclId")+",'"+MapGetter.getString(map,"vehiclenumber")+"'," +
								"'"+MapGetter.getString(map,"MsgESS_MsgTime")+"','"+MapGetter.getString(map,"TerminalID")+"'," +
										""+(StringUtil.isValid(MapGetter.getString(map,"engontime")) ? MapGetter.getString(map,"engontime"):null)+")");
		}
		if(listResult.size()>0){
			listResult.add("update  ParamCollectFlag set pcf_FinalmsgTime='"+dateTime+"' where pcf_flagId=4");
		}
		boolean flag=this.ms.batch(listResult);
		//二期优化：是否需要数据备份
		if(isbakTable.equals("1")){
			MyConnectDSTransDAO conn=new MyConnectDSTransDAO(true);
			boolean flager=conn.batch(listResult);
			if(!flager){
				System.out.println("dutyCycle无数据插入备份失败！！");
			}
		}
		if(flag){
			System.out.println("dutyCycle无数据插入成功---------------统计"+listResult.size()+"条");
		}else{
			System.out.println("dutyCycle无数据插入失败");
		}
		list=null;
		listResult=null;
	}
	/**
	 * 载重利用率为空或null或''的设备集合
	 * @param dateTime
	 * @return
	 */
	public List<Map<String,Object>> getDataNoLoadRate(String dateTime){
		StringBuffer Mql=new StringBuffer();
		String TableTime=dateTime.substring(0,10).replaceAll("-","");
		Mql.append(" with result as (select ");
		Mql.append(" runKm=case  VehicleRumKmID ");
		Mql.append(" when 1 then MsgESS_iRunKmExact ");
		Mql.append(" when 2 then MsgESS_iRunKmExact_ECM ");
		Mql.append(" when 3 then MsgESS_iRunKmECM ");
		Mql.append(" when 4 then MsgESS_iRunKmECU ");
		Mql.append(" when 5 then MsgESS_iRunKmGPS ");
		Mql.append(" else  MsgESS_iRunKmExact end, ");
		Mql.append(" msgess_vcl_id vclid,vv.vehiclenumber,vt.TerminalID ,msgess_iwork engOnTime,MsgESS_MsgTime='"+dateTime+"',");
		Mql.append(" loadratemethodid,MsgESS_AverageLoad,vcl_cargoquality,vcl_mustdragquality ");
		Mql.append(" from "+GlobalDBVar.getDBFullName_Conn("Msg_EquipmentState_Statistics_"+TableTime, "3", null)+" inner join v_vehicleinfo vv on msgess_vcl_id =vehicleid   ");
		Mql.append(" inner join V_Tmnl_Install vt on vv.Vehicleid=vt.Vehicleid  and installtime <getdate() and BackoutTime>getdate() ");
		Mql.append(" where MsgESS_State = 0 and( (subString(cast (MsgESS_Complete_1 as varchar),1,1) = 1 and charindex(cast(vehiclerumkmid as varchar)+'1',cast(MsgESS_Complete_2 as varchar)) >0)" +
				   " or (subString(cast (MsgESS_Complete_1 as varchar),1,1) = 0 and charindex(cast(vehiclerumkmid as varchar)+'0',cast(MsgESS_Complete_2 as varchar)) >0)) )");
		
		Mql.append(" SELECT vclid,engontime,vehiclenumber,terminalid,loadrate,MsgESS_MsgTime='"+dateTime+"'");
		Mql.append(" FROM   (SELECT vclid,engontime,vehiclenumber,terminalid,");
		Mql.append(" loadrate = CASE  WHEN engontime IS NULL  OR engontime <= 0 OR msgess_averageload IS NULL  OR msgess_averageload <= 0 THEN 0");
		Mql.append(" ELSE CASE loadratemethodid   WHEN 1 THEN CASE ");
		Mql.append(" WHEN Isnull(vcl_cargoquality - vcl_mustdragquality,0) = 0 THEN 0");
		Mql.append(" ELSE (msgess_averageload - vcl_mustdragquality) / (vcl_cargoquality - vcl_mustdragquality) END");
		Mql.append(" WHEN 2 THEN CASE    WHEN Isnull(vcl_cargoquality,0) = 0 THEN 0  ELSE msgess_averageload / vcl_cargoquality END");
		Mql.append(" ELSE 0   END END FROM   result  WHERE  runkm > 100) aa WHERE  (loadrate = 0 OR loadrate = '' OR loadrate IS NULL )");
		return msd.execQuery(Mql.toString(), new Object[]{});
	}
	/**
	 * 保存载重数据
	 * @param list
	 * @param dateTime
	 */
	public void saveDataNoLoadRate(List<Map<String,Object>>list,String dateTime,String isbakTable){
		List<String>listResult=new ArrayList<String>();//最终结果
		for(Map<String,Object>map:list){
				listResult.add("insert into LoadRateOfVcl (Lrov_vcl_id,Lrov_vclno,Lrov_msgTime,Lrov_tmnlno,Lrov_ECMrunTime)" +
						"values("+MapGetter.getString(map,"vclId")+",'"+MapGetter.getString(map,"vehiclenumber")+"'," +
								"'"+MapGetter.getString(map,"MsgESS_MsgTime")+"','"+MapGetter.getString(map,"TerminalID")+"'," +
										""+(StringUtil.isValid(MapGetter.getString(map,"engontime")) ? MapGetter.getString(map,"engontime"):null)+")");
		}
		if(listResult.size()>0){
			listResult.add("update  ParamCollectFlag set pcf_FinalmsgTime='"+dateTime+"' where pcf_flagId=5");
		}
		System.out.println(listResult.toString());
		boolean flag=this.ms.batch(listResult);
		//二期优化：是否需要数据备份
		if(isbakTable.equals("1")){
			MyConnectDSTransDAO conn=new MyConnectDSTransDAO(true);
			boolean flager =conn.batch(listResult);
			if(!flager){
				System.out.println("载重利用率为空数据插入失败！！");
			}
		}
		if(flag){
			System.out.println("载重利用率为空插入成功---------------统计"+listResult.size()+"条");
		}else{
			System.out.println("载重利用率为空插入失败");
		}
		list=null;
		listResult=null;
	}
	
	/**
	 * 里程选择不正确设备集合
	 * @param dateTime
	 * @return
	 */
	public List<Map<String,Object>> getDataNoRunKmid(String dateTime){
		StringBuffer Mql=new StringBuffer();
		String TableTime=dateTime.substring(0,10).replaceAll("-","");
		Mql.append(" with result as (select ");
		Mql.append(" runKm=case  VehicleRumKmID ");
		Mql.append(" when 1 then MsgESS_iRunKmExact ");
		Mql.append(" when 2 then MsgESS_iRunKmExact_ECM ");
		Mql.append(" when 3 then MsgESS_iRunKmECM ");
		Mql.append(" when 4 then MsgESS_iRunKmECU ");
		Mql.append(" when 5 then MsgESS_iRunKmGPS ");
		Mql.append(" else  MsgESS_iRunKmExact end, ");
		Mql.append(" msgess_vcl_id vclid,vv.vehiclenumber,vt.TerminalID,MsgESS_MsgTime='"+dateTime+"',");
		Mql.append(" MsgESS_iRunKmExact,MsgESS_iRunKmExact_ECM,MsgESS_iRunKmECM,MsgESS_iRunKmECU,MsgESS_iRunKmGPS ");
		Mql.append(" from "+GlobalDBVar.getDBFullName_Conn("Msg_EquipmentState_Statistics_"+TableTime, "3", null)+" inner join v_vehicleinfo vv on msgess_vcl_id =vehicleid  ");
		Mql.append(" inner join V_Tmnl_Install vt on vv.Vehicleid=vt.Vehicleid  and installtime <getdate() and BackoutTime>getdate() ");
		Mql.append(" where MsgESS_State = 0 and( (subString(cast (MsgESS_Complete_1 as varchar),1,1) = 1 and charindex(cast(vehiclerumkmid as varchar)+'1',cast(MsgESS_Complete_2 as varchar)) >0)" +
				   " or (subString(cast (MsgESS_Complete_1 as varchar),1,1) = 0 and charindex(cast(vehiclerumkmid as varchar)+'0',cast(MsgESS_Complete_2 as varchar)) >0)) )");
		Mql.append(" select  vclid,vehiclenumber,TerminalID ,MsgESS_MsgTime,runkm,MsgESS_iRunKmExact,MsgESS_iRunKmExact_ECM,MsgESS_iRunKmECM,");
		Mql.append(" MsgESS_iRunKmECU,MsgESS_iRunKmGPS from result where (runkm=0 or runkm is null )");
		Mql.append(" and (isnull(MsgESS_iRunKmExact,0)+isnull(MsgESS_iRunKmExact_ECM,0)+isnull(MsgESS_iRunKmECM,0)+isnull(MsgESS_iRunKmECU,0)+isnull(MsgESS_iRunKmGPS,0)>0) ");
		return baseDAO.execQuery(Mql.toString(), new Object[]{});
	}
	
	/**
	 * 里程选择不正确
	 * @param list
	 * @param dateTime
	 */
	public void saveDataNoRunKmid(List<Map<String,Object>>list,String dateTime,String isbakTable){
		List<String>listResult=new ArrayList<String>();//最终结果
		for(Map<String,Object>map:list){
				listResult.add("insert into RunKmOfVcl (RKOV_vcl_id,RKOV_vclno,RKOV_tmnlno,RKOV_msgTime,RKOV_iRunKmExact_ECM,RKOV_iRunKmECM," +
						"RKOV_iRunKmExact,RKOV_iRunKmGPS,RKOV_iRunKmECU)" +
						"values("+MapGetter.getString(map,"vclId")+",'"+MapGetter.getString(map,"vehiclenumber")+"'," +
						"'"+MapGetter.getString(map,"TerminalID")+"',"+
						"'"+MapGetter.getString(map,"MsgESS_MsgTime")+"',"
						+(StringUtil.isValid(MapGetter.getString(map,"MsgESS_iRunKmExact_ECM")) ? MapGetter.getString(map,"MsgESS_iRunKmExact_ECM"):null)+"," +
						""+(StringUtil.isValid(MapGetter.getString(map,"MsgESS_iRunKmECM")) ? MapGetter.getString(map,"MsgESS_iRunKmECM"):null)+","
						+(StringUtil.isValid(MapGetter.getString(map,"MsgESS_iRunKmExact")) ? MapGetter.getString(map,"MsgESS_iRunKmExact"):null)+","+
						""+(StringUtil.isValid(MapGetter.getString(map,"MsgESS_iRunKmGPS")) ? MapGetter.getString(map,"MsgESS_iRunKmGPS"):null)+","
						+(StringUtil.isValid(MapGetter.getString(map,"MsgESS_iRunKmECU")) ? MapGetter.getString(map,"MsgESS_iRunKmECU"):null)+")");
		}
		
		
		if(listResult.size()>0){
			listResult.add("update  ParamCollectFlag set pcf_FinalmsgTime='"+dateTime+"' where pcf_flagId=6");
		}
		boolean flag=this.ms.batch(listResult);
		if(isbakTable.equals("1")){
			MyConnectDSTransDAO conn=new MyConnectDSTransDAO(true);
			boolean flager=conn.batch(listResult);
			if(!flager){
				System.out.println("里程选择不正确数据备份插入失败！！");
			}
		}
		if(flag){
			System.out.println("里程选择不正确插入成功---------------统计"+listResult.size()+"条");
		}else{
			System.out.println("里程选择不正确插入失败");
		}
		list=null;
		listResult=null;
	
	}
}
